// usage:
// `mongo --host 127.0.0.1 --port 27017 --username cc --password cc cmdb fix_inner_model.js`

/*
脚本用途： 修复服下模型/模型属性/模型属性分组丢失问题
    网络： bk_switch,bk_router,bk_load_balance,bk_firewall
    中间件: bk_weblogic,bk_apache,bk_tomcat
    
实现原理：
    对所有的模型/模型属性/模型属性分组进行 get_or_create 操作，如果是 create 则采用新分配ID
 */

const cmdb = db.getSiblingDB('cmdb') ;

const models = [
    {
        'ispre': false,
        'description': '',
        'creator': 'cc_system',
        'bk_classification_id': 'bk_network',
        'bk_obj_id': 'bk_switch',
        'bk_obj_name': '交换机',
        'bk_ispaused': false,
        'bk_supplier_account': '0',
        'last_time': ISODate('2019-09-03T03:41:40.877Z'),
        'metadata': {
            'label': {}
        },
        'position': '{\"bk_network\":{\"x\":-200,\"y\":-50}}',
        'modifier': '',
        'create_time': ISODate('2019-09-03T03:41:40.877Z'),
        'bk_obj_icon': 'icon-cc-switch2'
    }, {
        'bk_classification_id': 'bk_network',
        'bk_obj_icon': 'icon-cc-router',
        'ispre': false,
        'description': '',
        'bk_supplier_account': '0',
        'metadata': {
            'label': {}
        },
        'bk_obj_id': 'bk_router',
        'bk_obj_name': '路由器',
        'modifier': '',
        'bk_ispaused': false,
        'position': '{\"bk_network\":{\"x\":-350,\"y\":-50}}',
        'creator': 'cc_system',
        'create_time': ISODate('2019-09-03T03:41:40.877Z'),
        'last_time': ISODate('2019-09-03T03:41:40.877Z')
    }, {
        'bk_classification_id': 'bk_network',
        'description': '',
        'creator': 'cc_system',
        'metadata': {
            'label': {}
        },
        'bk_obj_icon': 'icon-cc-balance',
        'bk_obj_name': '负载均衡',
        'bk_ispaused': false,
        'modifier': '',
        'bk_obj_id': 'bk_load_balance',
        'ispre': false,
        'position': '{\"bk_network\":{\"x\":-500,\"y\":-50}}',
        'bk_supplier_account': '0',
        'create_time': ISODate('2019-09-03T03:41:40.877Z'),
        'last_time': ISODate('2019-09-03T03:41:40.877Z')
    }, {
        'bk_obj_icon': 'icon-cc-firewall',
        'description': '',
        'creator': 'cc_system',
        'modifier': '',
        'last_time': ISODate('2019-09-03T03:41:40.877Z'),
        'metadata': {
            'label': {}
        },
        'bk_supplier_account': '0',
        'create_time': ISODate('2019-09-03T03:41:40.877Z'),
        'bk_obj_id': 'bk_firewall',
        'ispre': false,
        'position': '{\"bk_network\":{\"x\":-650,\"y\":-50}}',
        'bk_classification_id': 'bk_network',
        'bk_obj_name': '防火墙',
        'bk_ispaused': false
    }, {
        'bk_obj_id' : 'bk_apache',
        'bk_ispaused' : false,
        'metadata' : {
            'label' : {}
        },
        'bk_supplier_account' : '0',
        'last_time' : ISODate('2019-09-03T03:41:40.877Z'),
        'bk_obj_icon' : 'icon-cc-apache',
        'bk_obj_name' : 'apache',
        'position' : '{\"bk_middleware\":{\"x\":-500,\"y\":-50}}',
        'modifier' : '',
        'create_time' : ISODate('2019-09-03T03:41:40.877Z'),
        'bk_classification_id' : 'bk_middleware',
        'ispre' : false,
        'description' : '',
        'creator' : 'cc_system'
    }, {
        'metadata' : {
            'label' : {}
        },
        'position' : '{\"bk_middleware\":{\"x\":-350,\"y\":-50}}',
        'creator' : 'cc_system',
        'ispre' : false,
        'bk_supplier_account' : '0',
        'create_time' : ISODate('2019-09-03T03:41:40.877Z'),
        'last_time' : ISODate('2019-09-03T03:41:40.877Z'),
        'bk_classification_id' : 'bk_middleware',
        'description' : '',
        'modifier' : '',
        'bk_obj_icon' : 'icon-cc-tomcat',
        'bk_obj_id' : 'bk_tomcat',
        'bk_obj_name' : 'tomcat',
        'bk_ispaused' : false
    }, {
        'position' : '{\"bk_middleware\":{\"x\":-200,\"y\":-50}}',
        'description' : '',
        'create_time' : ISODate('2019-09-03T03:41:40.877Z'),
        'metadata' : {
            'label' : {}
        },
        'ispre' : false,
        'bk_ispaused' : false,
        'creator' : 'cc_system',
        'bk_obj_name' : 'weblogic',
        'bk_supplier_account' : '0',
        'last_time' : ISODate('2019-09-03T03:41:40.877Z'),
        'bk_classification_id' : 'bk_middleware',
        'bk_obj_icon' : 'icon-cc-weblogic',
        'bk_obj_id' : 'bk_weblogic',
        'modifier' : ''
    }] ;

const modelAttributes = [
    {
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'ispre': true,
    'bk_property_type': 'singlechar',
    'creator': 'cc_system',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_supplier_account': '0',
    'bk_property_index': 0,
    'unit': '',
    'editable': false,
    'bk_isapi': false,
    'bk_obj_id': 'bk_firewall',
    'bk_property_name': '固资编号',
    'isrequired': true,
    'isreadonly': false,
    'bk_issystem': false,
    'bk_property_id': 'bk_asset_id',
    'bk_property_group': 'default',
    'placeholder': '',
    'option': ''
}, {
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_id': 'bk_inst_name',
    'placeholder': '',
    'editable': true,
    'isreadonly': false,
    'bk_issystem': false,
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_firewall',
    'bk_property_name': '名称',
    'unit': '',
    'bk_property_index': 0,
    'option': '',
    'ispre': true,
    'isrequired': true,
    'bk_isapi': false,
    'bk_property_type': 'singlechar',
    'bk_supplier_account': '0',
    'bk_property_group': 'default',
    'creator': 'cc_system'
}, {
    'bk_supplier_account': '0',
    'bk_property_group': 'default',
    'placeholder': '',
    'bk_issystem': false,
    'bk_isapi': false,
    'bk_obj_id': 'bk_firewall',
    'isreadonly': false,
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_id': 'bk_sn',
    'bk_property_index': 0,
    'unit': '',
    'ispre': false,
    'option': '',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_name': 'SN',
    'editable': true,
    'isrequired': false,
    'bk_property_type': 'singlechar',
    'creator': 'cc_system'
}, {
    'bk_property_name': '用途',
    'ispre': false,
    'isrequired': false,
    'creator': 'cc_system',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_id': 'bk_func',
    'isreadonly': false,
    'bk_isapi': false,
    'bk_property_index': 0,
    'editable': true,
    'bk_property_type': 'singlechar',
    'option': '',
    'bk_supplier_account': '0',
    'bk_obj_id': 'bk_firewall',
    'placeholder': '',
    'bk_issystem': false,
    'bk_property_group': 'default',
    'unit': ''
}, {
    'bk_obj_id': 'bk_firewall',
    'bk_property_name': '厂商',
    'ispre': false,
    'isrequired': false,
    'bk_property_type': 'singlechar',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_supplier_account': '0',
    'bk_property_id': 'bk_vendor',
    'bk_property_index': 0,
    'bk_isapi': false,
    'creator': 'cc_system',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'placeholder': '',
    'option': '',
    'bk_property_group': 'default',
    'unit': '',
    'editable': true,
    'isreadonly': false,
    'bk_issystem': false
}, {
    'isrequired': false,
    'bk_issystem': false,
    'option': '',
    'creator': 'cc_system',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_firewall',
    'bk_property_name': '设备型号',
    'bk_property_group': 'default',
    'unit': '',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_supplier_account': '0',
    'bk_property_id': 'bk_model',
    'placeholder': '',
    'isreadonly': false,
    'bk_property_type': 'singlechar',
    'bk_property_index': 0,
    'editable': true,
    'ispre': false,
    'bk_isapi': false
}, {
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_supplier_account': '0',
    'bk_property_name': '管理IP',
    'placeholder': '',
    'isrequired': false,
    'bk_issystem': false,
    'bk_property_type': 'singlechar',
    'bk_property_id': 'bk_admin_ip',
    'bk_property_index': 0,
    'ispre': false,
    'bk_isapi': false,
    'bk_property_group': 'default',
    'isreadonly': false,
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_firewall',
    'unit': '',
    'editable': true,
    'option': '^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.((1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.){2}(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)(,(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.((1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.){2}(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d))*$',
    'creator': 'cc_system'
}, {
    'bk_isapi': false,
    'bk_property_type': 'singlechar',
    'creator': 'cc_system',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'placeholder': '',
    'isrequired': false,
    'isreadonly': false,
    'bk_issystem': false,
    'option': '',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_supplier_account': '0',
    'bk_obj_id': 'bk_firewall',
    'bk_property_name': '维护人',
    'bk_property_index': 0,
    'unit': '',
    'editable': true,
    'ispre': false,
    'bk_property_id': 'bk_operator',
    'bk_property_group': 'default'
}, {
    'bk_supplier_account': '0',
    'bk_property_id': 'bk_os_detail',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_firewall',
    'isreadonly': false,
    'bk_isapi': false,
    'bk_property_type': 'singlechar',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'isrequired': false,
    'bk_issystem': false,
    'ispre': false,
    'bk_property_name': '操作系统详情',
    'bk_property_group': 'default',
    'bk_property_index': 0,
    'unit': '',
    'placeholder': '',
    'editable': true,
    'option': '',
    'creator': 'cc_system'
}, {
    'bk_property_type': 'longchar',
    'bk_property_name': '详细描述',
    'bk_property_group': 'default',
    'isrequired': false,
    'isreadonly': false,
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_firewall',
    'editable': true,
    'ispre': false,
    'placeholder': '',
    'creator': 'cc_system',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_supplier_account': '0',
    'bk_property_id': 'bk_detail',
    'bk_property_index': 0,
    'unit': '',
    'bk_issystem': false,
    'bk_isapi': false,
    'option': ''
}, {
    'bk_isapi': false,
    'creator': 'cc_system',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_issystem': false,
    'option': [{
        'id': '1',
        'name': '待运营',
        'type': 'text',
        'is_default': false
    }, {
        'id': '2',
        'name': '运营中',
        'type': 'text',
        'is_default': false
    }, {
        'id': '3',
        'name': '已下架',
        'type': 'text',
        'is_default': false
    }],
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_supplier_account': '0',
    'bk_property_name': '运营状态',
    'bk_property_group': 'default',
    'bk_property_index': 0,
    'unit': '',
    'placeholder': '',
    'editable': true,
    'ispre': false,
    'bk_property_type': 'enum',
    'bk_obj_id': 'bk_firewall',
    'bk_property_id': 'bk_biz_status',
    'isrequired': false,
    'isreadonly': false
}, {
    'bk_obj_id': 'bk_load_balance',
    'bk_property_group': 'default',
    'bk_property_type': 'singlechar',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_id': 'bk_asset_id',
    'unit': '',
    'placeholder': '',
    'option': '',
    'bk_property_name': '固资编号',
    'editable': false,
    'isreadonly': false,
    'creator': 'cc_system',
    'bk_supplier_account': '0',
    'bk_property_index': 0,
    'ispre': true,
    'isrequired': true,
    'bk_issystem': false,
    'bk_isapi': false
}, {
    'bk_obj_id': 'bk_load_balance',
    'bk_issystem': false,
    'bk_isapi': false,
    'bk_property_type': 'singlechar',
    'bk_supplier_account': '0',
    'bk_property_name': '名称',
    'bk_property_group': 'default',
    'ispre': true,
    'isreadonly': false,
    'bk_property_id': 'bk_inst_name',
    'editable': true,
    'isrequired': true,
    'option': '',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'unit': '',
    'placeholder': '',
    'creator': 'cc_system',
    'bk_property_index': 0
}, {
    'bk_supplier_account': '0',
    'bk_property_id': 'bk_sn',
    'editable': true,
    'bk_property_group': 'default',
    'unit': '',
    'ispre': false,
    'isrequired': false,
    'bk_property_type': 'singlechar',
    'option': '',
    'creator': 'cc_system',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_name': 'SN',
    'bk_property_index': 0,
    'placeholder': '',
    'bk_issystem': false,
    'bk_isapi': false,
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_load_balance',
    'isreadonly': false
}, {
    'option': '',
    'bk_property_id': 'bk_func',
    'bk_property_group': 'default',
    'isrequired': false,
    'bk_issystem': false,
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_load_balance',
    'bk_property_index': 0,
    'placeholder': '',
    'bk_property_type': 'singlechar',
    'ispre': false,
    'isreadonly': false,
    'bk_isapi': false,
    'bk_supplier_account': '0',
    'bk_property_name': '用途',
    'unit': '',
    'editable': true,
    'creator': 'cc_system',
    'create_time': ISODate('2019-09-03T03:41:40.909Z')
}, {
    'bk_property_id': 'bk_vendor',
    'bk_property_name': '厂商',
    'placeholder': '',
    'editable': true,
    'isrequired': false,
    'bk_supplier_account': '0',
    'bk_obj_id': 'bk_load_balance',
    'bk_property_group': 'default',
    'bk_property_type': 'singlechar',
    'option': '',
    'bk_isapi': false,
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'unit': '',
    'ispre': false,
    'bk_issystem': false,
    'bk_property_index': 0,
    'isreadonly': false,
    'creator': 'cc_system',
    'last_time': ISODate('2019-09-03T03:41:40.909Z')
}, {
    'bk_supplier_account': '0',
    'bk_issystem': false,
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_load_balance',
    'editable': true,
    'isrequired': false,
    'isreadonly': false,
    'bk_isapi': false,
    'option': '',
    'creator': 'cc_system',
    'bk_property_id': 'bk_model',
    'bk_property_index': 0,
    'unit': '',
    'placeholder': '',
    'bk_property_type': 'singlechar',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_name': '设备型号',
    'bk_property_group': 'default',
    'ispre': false
}, {
    'bk_property_id': 'bk_admin_ip',
    'placeholder': '',
    'bk_property_type': 'singlechar',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'editable': true,
    'ispre': false,
    'isrequired': false,
    'option': '^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.((1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.){2}(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)(,(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.((1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.){2}(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d))*$',
    'creator': 'cc_system',
    'bk_isapi': false,
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_supplier_account': '0',
    'bk_obj_id': 'bk_load_balance',
    'bk_property_name': '管理IP',
    'bk_property_index': 0,
    'isreadonly': false,
    'bk_property_group': 'default',
    'unit': '',
    'bk_issystem': false
}, {
    'bk_issystem': false,
    'bk_isapi': false,
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_name': '维护人',
    'placeholder': '',
    'isreadonly': false,
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'isrequired': false,
    'bk_property_type': 'singlechar',
    'creator': 'cc_system',
    'bk_obj_id': 'bk_load_balance',
    'bk_property_id': 'bk_operator',
    'bk_property_group': 'default',
    'bk_property_index': 0,
    'unit': '',
    'bk_supplier_account': '0',
    'editable': true,
    'ispre': false,
    'option': ''
}, {
    'isreadonly': false,
    'bk_supplier_account': '0',
    'bk_property_group': 'default',
    'unit': '',
    'bk_isapi': false,
    'creator': 'cc_system',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_load_balance',
    'bk_property_id': 'bk_os_detail',
    'bk_property_index': 0,
    'bk_issystem': false,
    'bk_property_type': 'singlechar',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'placeholder': '',
    'ispre': false,
    'isrequired': false,
    'option': '',
    'bk_property_name': '操作系统详情',
    'editable': true
}, {
    'placeholder': '',
    'editable': true,
    'bk_isapi': false,
    'option': '',
    'creator': 'cc_system',
    'bk_property_group': 'default',
    'unit': '',
    'bk_property_id': 'bk_detail',
    'ispre': false,
    'isrequired': false,
    'bk_property_type': 'longchar',
    'bk_obj_id': 'bk_load_balance',
    'bk_property_index': 0,
    'isreadonly': false,
    'bk_issystem': false,
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_supplier_account': '0',
    'bk_property_name': '详细描述'
}, {
    'isrequired': false,
    'isreadonly': false,
    'bk_supplier_account': '0',
    'unit': '',
    'editable': true,
    'option': [{
        'type': 'text',
        'is_default': false,
        'id': '1',
        'name': '待运营'
    }, {
        'id': '2',
        'name': '运营中',
        'type': 'text',
        'is_default': false
    }, {
        'id': '3',
        'name': '已下架',
        'type': 'text',
        'is_default': false
    }],
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_load_balance',
    'bk_property_name': '运营状态',
    'ispre': false,
    'bk_property_type': 'enum',
    'bk_property_index': 0,
    'placeholder': '',
    'bk_issystem': false,
    'bk_isapi': false,
    'creator': 'cc_system',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_id': 'bk_biz_status',
    'bk_property_group': 'default'
}, {
    'bk_obj_id': 'bk_router',
    'bk_property_group': 'default',
    'placeholder': '',
    'bk_property_type': 'singlechar',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_supplier_account': '0',
    'bk_property_id': 'bk_asset_id',
    'bk_issystem': false,
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_name': '固资编号',
    'unit': '',
    'editable': false,
    'isrequired': true,
    'isreadonly': false,
    'bk_isapi': false,
    'bk_property_index': 0,
    'ispre': true,
    'option': '',
    'creator': 'cc_system'
}, {
    'option': '',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_router',
    'bk_property_name': '名称',
    'isrequired': true,
    'isreadonly': false,
    'unit': '',
    'bk_issystem': false,
    'bk_isapi': false,
    'creator': 'cc_system',
    'bk_property_id': 'bk_inst_name',
    'bk_property_group': 'default',
    'editable': true,
    'ispre': true,
    'bk_property_type': 'singlechar',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_supplier_account': '0',
    'bk_property_index': 0,
    'placeholder': ''
}, {
    'option': '',
    'creator': 'cc_system',
    'bk_property_index': 0,
    'placeholder': '',
    'bk_issystem': false,
    'unit': '',
    'bk_property_type': 'singlechar',
    'bk_obj_id': 'bk_router',
    'bk_property_id': 'bk_sn',
    'isreadonly': false,
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_supplier_account': '0',
    'editable': true,
    'isrequired': false,
    'bk_isapi': false,
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_name': 'SN',
    'bk_property_group': 'default',
    'ispre': false
}, {
    'bk_isapi': false,
    'option': '',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_router',
    'bk_property_index': 0,
    'isrequired': false,
    'isreadonly': false,
    'bk_property_id': 'bk_func',
    'bk_property_type': 'singlechar',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'unit': '',
    'editable': true,
    'ispre': false,
    'creator': 'cc_system',
    'bk_supplier_account': '0',
    'bk_property_name': '用途',
    'bk_property_group': 'default',
    'placeholder': '',
    'bk_issystem': false
}, {
    'bk_property_group': 'default',
    'ispre': false,
    'bk_property_id': 'bk_vendor',
    'bk_property_name': '厂商',
    'unit': '',
    'placeholder': '',
    'editable': true,
    'isrequired': false,
    'bk_isapi': false,
    'creator': 'cc_system',
    'bk_property_index': 0,
    'isreadonly': false,
    'bk_property_type': 'singlechar',
    'option': '',
    'bk_supplier_account': '0',
    'bk_obj_id': 'bk_router',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_issystem': false,
    'create_time': ISODate('2019-09-03T03:41:40.909Z')
}, {
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_id': 'bk_model',
    'isreadonly': false,
    'editable': true,
    'option': '',
    'creator': 'cc_system',
    'bk_supplier_account': '0',
    'bk_obj_id': 'bk_router',
    'unit': '',
    'placeholder': '',
    'ispre': false,
    'bk_issystem': false,
    'bk_property_type': 'singlechar',
    'bk_isapi': false,
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_name': '设备型号',
    'bk_property_group': 'default',
    'bk_property_index': 0,
    'isrequired': false
}, {
    'bk_obj_id': 'bk_router',
    'bk_property_id': 'bk_admin_ip',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_supplier_account': '0',
    'placeholder': '',
    'ispre': false,
    'bk_isapi': false,
    'unit': '',
    'bk_property_group': 'default',
    'creator': 'cc_system',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_index': 0,
    'editable': true,
    'isrequired': false,
    'isreadonly': false,
    'bk_issystem': false,
    'bk_property_type': 'singlechar',
    'option': '^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.((1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.){2}(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)(,(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.((1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.){2}(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d))*$',
    'bk_property_name': '管理IP'
}, {
    'bk_issystem': false,
    'bk_isapi': false,
    'placeholder': '',
    'isrequired': false,
    'isreadonly': false,
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_supplier_account': '0',
    'bk_property_name': '维护人',
    'unit': '',
    'editable': true,
    'option': '',
    'bk_obj_id': 'bk_router',
    'bk_property_group': 'default',
    'bk_property_index': 0,
    'creator': 'cc_system',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_id': 'bk_operator',
    'ispre': false,
    'bk_property_type': 'singlechar'
}, {
    'placeholder': '',
    'unit': '',
    'ispre': false,
    'bk_issystem': false,
    'bk_isapi': false,
    'bk_property_type': 'singlechar',
    'bk_property_id': 'bk_os_detail',
    'bk_property_index': 0,
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_router',
    'isreadonly': false,
    'bk_property_name': '操作系统详情',
    'bk_property_group': 'default',
    'editable': true,
    'isrequired': false,
    'option': '',
    'bk_supplier_account': '0',
    'creator': 'cc_system'
}, {
    'bk_property_group': 'default',
    'bk_property_index': 0,
    'ispre': false,
    'bk_issystem': false,
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_id': 'bk_detail',
    'bk_supplier_account': '0',
    'bk_obj_id': 'bk_router',
    'unit': '',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'editable': true,
    'isreadonly': false,
    'placeholder': '',
    'isrequired': false,
    'bk_isapi': false,
    'bk_property_type': 'longchar',
    'option': '',
    'creator': 'cc_system',
    'bk_property_name': '详细描述'
}, {
    'bk_supplier_account': '0',
    'bk_property_name': '运营状态',
    'ispre': false,
    'bk_issystem': false,
    'bk_isapi': false,
    'bk_obj_id': 'bk_router',
    'bk_property_group': 'default',
    'option': [{
        'name': '待运营',
        'type': 'text',
        'is_default': false,
        'id': '1'
    }, {
        'is_default': false,
        'id': '2',
        'name': '运营中',
        'type': 'text'
    }, {
        'name': '已下架',
        'type': 'text',
        'is_default': false,
        'id': '3'
    }],
    'creator': 'cc_system',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_id': 'bk_biz_status',
    'isreadonly': false,
    'bk_property_type': 'enum',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_index': 0,
    'unit': '',
    'placeholder': '',
    'editable': true,
    'isrequired': false
}, {
    'isrequired': true,
    'isreadonly': false,
    'bk_property_type': 'singlechar',
    'creator': 'cc_system',
    'bk_supplier_account': '0',
    'unit': '',
    'bk_isapi': false,
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_id': 'bk_asset_id',
    'editable': false,
    'option': '',
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'placeholder': '',
    'bk_obj_id': 'bk_switch',
    'bk_property_name': '固资编号',
    'bk_property_group': 'default',
    'bk_property_index': 0,
    'ispre': true,
    'bk_issystem': false
}, {
    'bk_isapi': false,
    'option': '',
    'creator': 'cc_system',
    'bk_obj_id': 'bk_switch',
    'unit': '',
    'placeholder': '',
    'editable': true,
    'isreadonly': false,
    'bk_supplier_account': '0',
    'bk_property_id': 'bk_inst_name',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_group': 'default',
    'bk_property_index': 0,
    'ispre': true,
    'bk_issystem': false,
    'bk_property_name': '名称',
    'isrequired': true,
    'bk_property_type': 'singlechar'
}, {
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'isrequired': false,
    'bk_isapi': false,
    'bk_property_type': 'singlechar',
    'bk_supplier_account': '0',
    'ispre': false,
    'isreadonly': false,
    'option': '',
    'bk_property_id': 'bk_sn',
    'unit': '',
    'placeholder': '',
    'bk_property_index': 0,
    'editable': true,
    'bk_issystem': false,
    'creator': 'cc_system',
    'bk_obj_id': 'bk_switch',
    'bk_property_name': 'SN',
    'bk_property_group': 'default'
}, {
    'isrequired': false,
    'option': '',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_group': 'default',
    'ispre': false,
    'placeholder': '',
    'isreadonly': false,
    'bk_property_type': 'singlechar',
    'creator': 'cc_system',
    'bk_property_name': '用途',
    'bk_property_index': 0,
    'unit': '',
    'bk_obj_id': 'bk_switch',
    'editable': true,
    'bk_isapi': false,
    'bk_supplier_account': '0',
    'bk_property_id': 'bk_func',
    'bk_issystem': false
}, {
    'ispre': false,
    'bk_issystem': false,
    'option': '',
    'bk_property_id': 'bk_vendor',
    'placeholder': '',
    'editable': true,
    'bk_property_group': 'default',
    'bk_property_index': 0,
    'bk_isapi': false,
    'creator': 'cc_system',
    'bk_supplier_account': '0',
    'unit': '',
    'isrequired': false,
    'bk_property_type': 'singlechar',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_switch',
    'bk_property_name': '厂商',
    'isreadonly': false
}, {
    'bk_property_group': 'default',
    'isreadonly': false,
    'option': '',
    'unit': '',
    'bk_isapi': false,
    'bk_property_type': 'singlechar',
    'bk_supplier_account': '0',
    'bk_obj_id': 'bk_switch',
    'bk_property_id': 'bk_model',
    'placeholder': '',
    'editable': true,
    'ispre': false,
    'isrequired': false,
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_name': '设备型号',
    'bk_property_index': 0,
    'bk_issystem': false,
    'creator': 'cc_system',
    'create_time': ISODate('2019-09-03T03:41:40.909Z')
}, {
    'unit': '',
    'editable': true,
    'ispre': false,
    'bk_supplier_account': '0',
    'bk_obj_id': 'bk_switch',
    'bk_property_group': 'default',
    'bk_property_index': 0,
    'isreadonly': false,
    'bk_isapi': false,
    'bk_property_type': 'singlechar',
    'creator': 'cc_system',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_name': '管理IP',
    'bk_issystem': false,
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_id': 'bk_admin_ip',
    'placeholder': '',
    'isrequired': false,
    'option': '^((1?\\d{1,2}|2[0-4]\\d|25[0-5])[.]){3}(1?\\d{1,2}|2[0-4]\\d|25[0-5])(,((1?\\d{1,2}|2[0-4]\\d|25[0-5])[.]){3}(1?\\d{1,2}|2[0-4]\\d|25[0-5]))*$'
}, {
    'bk_property_id': 'bk_operator',
    'bk_property_group': 'default',
    'isreadonly': false,
    'option': '',
    'creator': 'cc_system',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_switch',
    'bk_property_name': '维护人',
    'ispre': false,
    'isrequired': false,
    'bk_issystem': false,
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_property_index': 0,
    'bk_isapi': false,
    'bk_property_type': 'singlechar',
    'bk_supplier_account': '0',
    'unit': '',
    'placeholder': '',
    'editable': true
}, {
    'bk_obj_id': 'bk_switch',
    'bk_issystem': false,
    'bk_property_type': 'singlechar',
    'creator': 'cc_system',
    'bk_property_group': 'default',
    'placeholder': '',
    'editable': true,
    'ispre': false,
    'isreadonly': false,
    'option': '',
    'isrequired': false,
    'bk_isapi': false,
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_supplier_account': '0',
    'bk_property_id': 'bk_os_detail',
    'bk_property_name': '操作系统详情',
    'bk_property_index': 0,
    'unit': ''
}, {
    'bk_property_index': 0,
    'placeholder': '',
    'bk_property_type': 'longchar',
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_supplier_account': '0',
    'editable': true,
    'isrequired': false,
    'option': '',
    'bk_property_name': '详细描述',
    'bk_property_group': 'default',
    'unit': '',
    'isreadonly': false,
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_switch',
    'bk_property_id': 'bk_detail',
    'ispre': false,
    'bk_issystem': false,
    'bk_isapi': false,
    'creator': 'cc_system'
}, {
    'bk_property_index': 0,
    'editable': true,
    'ispre': false,
    'create_time': ISODate('2019-09-03T03:41:40.909Z'),
    'last_time': ISODate('2019-09-03T03:41:40.909Z'),
    'bk_obj_id': 'bk_switch',
    'bk_property_group': 'default',
    'bk_issystem': false,
    'bk_property_type': 'enum',
    'isrequired': false,
    'isreadonly': false,
    'creator': 'cc_system',
    'bk_supplier_account': '0',
    'bk_property_id': 'bk_biz_status',
    'unit': '',
    'placeholder': '',
    'bk_property_name': '运营状态',
    'bk_isapi': false,
    'option': [{
        'id': '1',
        'name': '待运营',
        'type': 'text',
        'is_default': false
    }, {
        'id': '2',
        'name': '运营中',
        'type': 'text',
        'is_default': false
    }, {
        'id': '3',
        'name': '已下架',
        'type': 'text',
        'is_default': false
    }]
}, {
    "bk_supplier_account" : "0",
    "bk_obj_id" : "bk_apache",
    "unit" : "",
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "placeholder" : "",
    "ispre" : true,
    "isrequired" : true,
    "bk_isapi" : false,
    "option" : "",
    "creator" : "cc_system",
    "bk_property_id" : "bk_inst_key",
    "bk_property_name" : "中间件标识",
    "bk_property_group" : "default",
    "bk_property_index" : NumberLong(0),
    "isreadonly" : false,
    "bk_issystem" : false,
    "bk_property_type" : "singlechar",
    "editable" : false
}, {
        "bk_property_group" : "default",
        "placeholder" : "",
        "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "creator" : "cc_system",
        "bk_property_name" : "名称",
        "editable" : true,
        "isreadonly" : false,
        "bk_issystem" : false,
        "bk_isapi" : false,
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_supplier_account" : "0",
        "bk_obj_id" : "bk_apache",
        "bk_property_index" : NumberLong(0),
        "isrequired" : true,
        "bk_property_type" : "singlechar",
        "option" : "",
        "bk_property_id" : "bk_inst_name",
        "unit" : "",
        "ispre" : true
    }, {
        "bk_supplier_account" : "0",
        "unit" : "",
        "placeholder" : "",
        "bk_isapi" : false,
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_obj_id" : "bk_apache",
        "bk_property_id" : "bk_version",
        "editable" : true,
        "isrequired" : false,
        "isreadonly" : false,
        "bk_property_type" : "longchar",
        "option" : "",
        "bk_property_index" : NumberLong(0),
        "ispre" : false,
        "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_property_name" : "版本",
        "bk_property_group" : "default",
        "bk_issystem" : false,
        "creator" : "cc_system"
    }, {
        "isreadonly" : false,
        "bk_issystem" : false,
        "bk_property_type" : "longchar",
        "creator" : "cc_system",
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "unit" : "",
        "editable" : true,
        "bk_property_name" : "补丁版本",
        "bk_property_group" : "default",
        "bk_property_index" : NumberLong(0),
        "placeholder" : "",
        "ispre" : false,
        "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_supplier_account" : "0",
        "option" : "",
        "bk_obj_id" : "bk_apache",
        "bk_isapi" : false,
        "bk_property_id" : "bk_patch_version",
        "isrequired" : false
    }, {
        "bk_property_name" : "主目录",
        "bk_property_group" : "default",
        "placeholder" : "",
        "isrequired" : false,
        "bk_isapi" : false,
        "bk_property_type" : "longchar",
        "bk_obj_id" : "bk_apache",
        "bk_property_id" : "bk_main_path",
        "bk_property_index" : NumberLong(0),
        "ispre" : false,
        "bk_issystem" : false,
        "unit" : "",
        "isreadonly" : false,
        "creator" : "cc_system",
        "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_supplier_account" : "0",
        "editable" : true,
        "option" : ""
    }, {
        "bk_obj_id" : "bk_apache",
        "bk_property_name" : "日志路径",
        "placeholder" : "",
        "bk_isapi" : false,
        "creator" : "cc_system",
        "bk_property_id" : "bk_log_path",
        "isrequired" : false,
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_supplier_account" : "0",
        "unit" : "",
        "ispre" : false,
        "isreadonly" : false,
        "bk_issystem" : false,
        "bk_property_type" : "longchar",
        "bk_property_group" : "default",
        "bk_property_index" : NumberLong(0),
        "editable" : true,
        "option" : "",
        "create_time" : ISODate("2019-09-03T03:41:40.909Z")
    }, {
        "bk_supplier_account" : "0",
        "bk_obj_id" : "bk_apache",
        "bk_property_id" : "bk_vendor",
        "bk_property_index" : NumberLong(0),
        "bk_issystem" : false,
        "placeholder" : "",
        "bk_property_type" : "singlechar",
        "creator" : "cc_system",
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_property_name" : "厂商",
        "bk_property_group" : "default",
        "editable" : true,
        "bk_isapi" : false,
        "option" : "",
        "unit" : "",
        "ispre" : false,
        "isrequired" : false,
        "isreadonly" : false,
        "create_time" : ISODate("2019-09-03T03:41:40.909Z")
    }, {
        "bk_isapi" : false,
        "creator" : "cc_system",
        "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_property_index" : NumberLong(0),
        "bk_obj_id" : "bk_apache",
        "bk_property_id" : "bk_ip",
        "editable" : true,
        "ispre" : false,
        "isrequired" : false,
        "bk_issystem" : false,
        "option" : "^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.((1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.){2}(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)(,(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.((1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.){2}(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d))*$",
        "bk_property_type" : "singlechar",
        "placeholder" : "",
        "isreadonly" : false,
        "unit" : "",
        "bk_property_name" : "IP地址",
        "bk_property_group" : "default",
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_supplier_account" : "0"
    }, {
        "bk_property_type" : "singlechar",
        "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_obj_id" : "bk_apache",
        "placeholder" : "",
        "editable" : true,
        "bk_issystem" : false,
        "unit" : "",
        "isrequired" : false,
        "isreadonly" : false,
        "bk_supplier_account" : "0",
        "bk_property_id" : "bk_port",
        "bk_property_index" : NumberLong(0),
        "option" : "",
        "bk_property_name" : "端口",
        "ispre" : false,
        "bk_isapi" : false,
        "creator" : "cc_system",
        "bk_property_group" : "default",
        "last_time" : ISODate("2019-09-03T03:41:40.909Z")
    }, {
        "bk_property_name" : "详细描述",
        "bk_supplier_account" : "0",
        "option" : "",
        "bk_property_group" : "default",
        "unit" : "",
        "bk_issystem" : false,
        "creator" : "cc_system",
        "bk_obj_id" : "bk_apache",
        "bk_property_id" : "bk_detail",
        "bk_property_index" : NumberLong(0),
        "placeholder" : "",
        "editable" : true,
        "ispre" : false,
        "isrequired" : false,
        "isreadonly" : false,
        "bk_property_type" : "longchar",
        "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_isapi" : false
    }, {
        "bk_property_index" : NumberLong(0),
        "ispre" : false,
        "option" : {
            "max" : "",
            "min" : ""
        },
        "creator" : "cc_system",
        "bk_supplier_account" : "0",
        "bk_obj_id" : "bk_apache",
        "bk_issystem" : false,
        "bk_isapi" : false,
        "bk_property_type" : "int",
        "editable" : true,
        "bk_property_id" : "bk_max_connect",
        "unit" : "",
        "bk_property_group" : "default",
        "placeholder" : "",
        "isrequired" : false,
        "isreadonly" : false,
        "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_property_name" : "最大连接请求数"
    }, {
        "bk_supplier_account" : "0",
        "placeholder" : "",
        "ispre" : false,
        "option" : {
            "min" : "",
            "max" : ""
        },
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_property_name" : "最大keepAlive请求数",
        "bk_property_index" : NumberLong(0),
        "bk_isapi" : false,
        "bk_property_type" : "int",
        "bk_property_id" : "bk_max_keepalive",
        "bk_property_group" : "default",
        "unit" : "",
        "editable" : true,
        "isreadonly" : false,
        "bk_issystem" : false,
        "bk_obj_id" : "bk_apache",
        "isrequired" : false,
        "creator" : "cc_system",
        "create_time" : ISODate("2019-09-03T03:41:40.909Z")
    }, {
        "bk_isapi" : false,
        "option" : "",
        "bk_supplier_account" : "0",
        "bk_property_group" : "default",
        "placeholder" : "",
        "isrequired" : true,
        "bk_issystem" : false,
        "bk_property_id" : "bk_inst_key",
        "bk_property_name" : "中间件标识",
        "bk_property_index" : NumberLong(0),
        "bk_property_type" : "singlechar",
        "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "isreadonly" : false,
        "creator" : "cc_system",
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_obj_id" : "bk_tomcat",
        "unit" : "",
        "editable" : false,
        "ispre" : true
    }, {
        "bk_property_group" : "default",
        "isrequired" : true,
        "bk_issystem" : false,
        "option" : "",
        "creator" : "cc_system",
        "bk_obj_id" : "bk_tomcat",
        "bk_property_id" : "bk_inst_name",
        "bk_property_name" : "名称",
        "isreadonly" : false,
        "bk_supplier_account" : "0",
        "bk_property_index" : NumberLong(0),
        "unit" : "",
        "placeholder" : "",
        "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "editable" : true,
        "ispre" : true,
        "bk_isapi" : false,
        "bk_property_type" : "singlechar"
    }, {
        "bk_property_id" : "bk_version",
        "unit" : "",
        "editable" : true,
        "isreadonly" : false,
        "bk_issystem" : false,
        "bk_isapi" : false,
        "bk_property_type" : "longchar",
        "creator" : "cc_system",
        "bk_obj_id" : "bk_tomcat",
        "placeholder" : "",
        "isrequired" : false,
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_property_index" : NumberLong(0),
        "bk_supplier_account" : "0",
        "bk_property_group" : "default",
        "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_property_name" : "版本",
        "ispre" : false,
        "option" : ""
    }, {
        "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_property_group" : "default",
        "bk_issystem" : false,
        "bk_isapi" : false,
        "bk_property_type" : "longchar",
        "bk_obj_id" : "bk_tomcat",
        "creator" : "cc_system",
        "isreadonly" : false,
        "option" : "",
        "bk_property_name" : "补丁版本",
        "unit" : "",
        "placeholder" : "",
        "editable" : true,
        "ispre" : false,
        "isrequired" : false,
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_supplier_account" : "0",
        "bk_property_id" : "bk_patch_version",
        "bk_property_index" : NumberLong(0)
    }, {
        "bk_obj_id" : "bk_tomcat",
        "bk_property_name" : "主目录",
        "unit" : "",
        "isrequired" : false,
        "option" : "",
        "creator" : "cc_system",
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_supplier_account" : "0",
        "bk_property_index" : NumberLong(0),
        "placeholder" : "",
        "ispre" : false,
        "bk_issystem" : false,
        "bk_isapi" : false,
        "bk_property_group" : "default",
        "editable" : true,
        "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_property_id" : "bk_main_path",
        "isreadonly" : false,
        "bk_property_type" : "longchar"
    }, {
        "creator" : "cc_system",
        "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_supplier_account" : "0",
        "bk_property_group" : "default",
        "bk_property_index" : NumberLong(0),
        "isreadonly" : false,
        "bk_property_id" : "bk_log_path",
        "bk_property_name" : "日志路径",
        "placeholder" : "",
        "isrequired" : false,
        "bk_property_type" : "longchar",
        "editable" : true,
        "ispre" : false,
        "bk_isapi" : false,
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_obj_id" : "bk_tomcat",
        "unit" : "",
        "bk_issystem" : false,
        "option" : ""
    }, {
        "unit" : "",
        "editable" : true,
        "ispre" : false,
        "isrequired" : false,
        "bk_issystem" : false,
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_supplier_account" : "0",
        "bk_property_id" : "bk_vendor",
        "bk_property_index" : NumberLong(0),
        "isreadonly" : false,
        "bk_property_type" : "singlechar",
        "bk_obj_id" : "bk_tomcat",
        "option" : "",
        "creator" : "cc_system",
        "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_property_name" : "厂商",
        "bk_property_group" : "default",
        "placeholder" : "",
        "bk_isapi" : false
    }, {
        "unit" : "",
        "editable" : true,
        "ispre" : false,
        "isreadonly" : false,
        "isrequired" : false,
        "bk_property_type" : "singlechar",
        "option" : "^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.((1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.){2}(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)(,(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.((1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.){2}(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d))*$",
        "bk_obj_id" : "bk_tomcat",
        "bk_property_id" : "bk_ip",
        "bk_property_group" : "default",
        "bk_issystem" : false,
        "creator" : "cc_system",
        "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
        "bk_supplier_account" : "0",
        "bk_property_name" : "IP地址",
        "bk_property_index" : NumberLong(0),
        "placeholder" : "",
        "bk_isapi" : false
    }, {
    "bk_obj_id" : "bk_tomcat",
    "unit" : "",
    "isrequired" : false,
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_supplier_account" : "0",
    "placeholder" : "",
    "editable" : true,
    "ispre" : false,
    "bk_property_id" : "bk_port",
    "bk_property_name" : "端口",
    "bk_property_group" : "default",
    "bk_property_index" : NumberLong(0),
    "isreadonly" : false,
    "bk_issystem" : false,
    "bk_isapi" : false,
    "creator" : "cc_system",
    "option" : "",
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_property_type" : "singlechar"
}, {
    "bk_obj_id" : "bk_tomcat",
    "bk_property_index" : NumberLong(0),
    "editable" : true,
    "ispre" : false,
    "isrequired" : false,
    "option" : "",
    "bk_supplier_account" : "0",
    "creator" : "cc_system",
    "bk_isapi" : false,
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_property_name" : "详细描述",
    "bk_property_id" : "bk_detail",
    "unit" : "",
    "placeholder" : "",
    "bk_issystem" : false,
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "isreadonly" : false,
    "bk_property_type" : "longchar",
    "bk_property_group" : "default"
}, {
    "ispre" : false,
    "isrequired" : false,
    "creator" : "cc_system",
    "bk_supplier_account" : "0",
    "bk_obj_id" : "bk_tomcat",
    "unit" : "",
    "placeholder" : "",
    "editable" : true,
    "bk_property_id" : "bk_jdk_version",
    "bk_property_name" : "JDK版本",
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_property_group" : "default",
    "isreadonly" : false,
    "bk_issystem" : false,
    "bk_isapi" : false,
    "option" : "",
    "bk_property_index" : NumberLong(0),
    "bk_property_type" : "longchar"
}, {
    "creator" : "cc_system",
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_obj_id" : "bk_weblogic",
    "bk_property_name" : "中间件标识",
    "bk_property_index" : NumberLong(0),
    "bk_isapi" : false,
    "isrequired" : true,
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_supplier_account" : "0",
    "bk_property_id" : "bk_inst_key",
    "placeholder" : "",
    "ispre" : true,
    "bk_issystem" : false,
    "bk_property_type" : "singlechar",
    "bk_property_group" : "default",
    "editable" : false,
    "isreadonly" : false,
    "unit" : "",
    "option" : ""
}, {
    "bk_property_group" : "default",
    "isreadonly" : false,
    "bk_isapi" : false,
    "bk_property_name" : "名称",
    "creator" : "cc_system",
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_supplier_account" : "0",
    "bk_obj_id" : "bk_weblogic",
    "bk_property_index" : NumberLong(0),
    "unit" : "",
    "ispre" : true,
    "bk_property_id" : "bk_inst_name",
    "placeholder" : "",
    "editable" : true,
    "isrequired" : true,
    "bk_issystem" : false,
    "bk_property_type" : "singlechar",
    "option" : "",
    "create_time" : ISODate("2019-09-03T03:41:40.909Z")
}, {
    "ispre" : false,
    "bk_property_group" : "default",
    "placeholder" : "",
    "editable" : true,
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "unit" : "",
    "option" : "",
    "bk_property_id" : "bk_version",
    "isrequired" : false,
    "bk_issystem" : false,
    "bk_property_type" : "longchar",
    "bk_supplier_account" : "0",
    "bk_obj_id" : "bk_weblogic",
    "bk_isapi" : false,
    "creator" : "cc_system",
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_property_name" : "版本",
    "bk_property_index" : NumberLong(0),
    "isreadonly" : false
}, {
    "isrequired" : false,
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_supplier_account" : "0",
    "unit" : "",
    "placeholder" : "",
    "isreadonly" : false,
    "bk_issystem" : false,
    "option" : "",
    "bk_property_id" : "bk_patch_version",
    "bk_property_name" : "补丁版本",
    "editable" : true,
    "bk_property_group" : "default",
    "bk_property_index" : NumberLong(0),
    "bk_isapi" : false,
    "bk_property_type" : "longchar",
    "creator" : "cc_system",
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_obj_id" : "bk_weblogic",
    "ispre" : false
}, {
    "bk_isapi" : false,
    "bk_property_type" : "longchar",
    "bk_obj_id" : "bk_weblogic",
    "bk_property_id" : "bk_main_path",
    "bk_property_group" : "default",
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "editable" : true,
    "isreadonly" : false,
    "option" : "",
    "ispre" : false,
    "isrequired" : false,
    "creator" : "cc_system",
    "bk_property_index" : NumberLong(0),
    "placeholder" : "",
    "bk_issystem" : false,
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_supplier_account" : "0",
    "bk_property_name" : "主目录",
    "unit" : ""
}, {
    "ispre" : false,
    "isrequired" : false,
    "creator" : "cc_system",
    "bk_supplier_account" : "0",
    "bk_obj_id" : "bk_weblogic",
    "placeholder" : "",
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_property_name" : "日志路径",
    "unit" : "",
    "bk_isapi" : false,
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_property_group" : "default",
    "bk_property_index" : NumberLong(0),
    "editable" : true,
    "isreadonly" : false,
    "option" : "",
    "bk_property_id" : "bk_log_path",
    "bk_issystem" : false,
    "bk_property_type" : "longchar"
}, {
    "bk_property_type" : "singlechar",
    "option" : "",
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "ispre" : false,
    "bk_obj_id" : "bk_weblogic",
    "bk_property_id" : "bk_vendor",
    "bk_property_name" : "厂商",
    "bk_property_group" : "default",
    "unit" : "",
    "bk_property_index" : NumberLong(0),
    "isreadonly" : false,
    "creator" : "cc_system",
    "bk_isapi" : false,
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_supplier_account" : "0",
    "placeholder" : "",
    "editable" : true,
    "isrequired" : false,
    "bk_issystem" : false
}, {
    "unit" : "",
    "bk_issystem" : false,
    "creator" : "cc_system",
    "bk_obj_id" : "bk_weblogic",
    "bk_property_index" : NumberLong(0),
    "placeholder" : "",
    "isrequired" : false,
    "isreadonly" : false,
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_property_group" : "default",
    "editable" : true,
    "option" : "^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.((1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.){2}(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)(,(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.((1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.){2}(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d))*$",
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_supplier_account" : "0",
    "bk_property_id" : "bk_ip",
    "bk_property_name" : "IP地址",
    "ispre" : false,
    "bk_isapi" : false,
    "bk_property_type" : "singlechar"
}, {
    "bk_supplier_account" : "0",
    "bk_property_id" : "bk_port",
    "bk_property_index" : NumberLong(0),
    "placeholder" : "",
    "isrequired" : false,
    "creator" : "cc_system",
    "bk_obj_id" : "bk_weblogic",
    "ispre" : false,
    "bk_issystem" : false,
    "bk_property_group" : "default",
    "unit" : "",
    "isreadonly" : false,
    "bk_property_type" : "singlechar",
    "option" : "",
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_property_name" : "端口",
    "editable" : true,
    "bk_isapi" : false,
    "last_time" : ISODate("2019-09-03T03:41:40.909Z")
}, {
    "unit" : "",
    "isreadonly" : false,
    "bk_property_type" : "longchar",
    "option" : "",
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_supplier_account" : "0",
    "bk_property_name" : "详细描述",
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "editable" : true,
    "bk_issystem" : false,
    "bk_property_index" : NumberLong(0),
    "creator" : "cc_system",
    "bk_property_group" : "default",
    "placeholder" : "",
    "ispre" : false,
    "isrequired" : false,
    "bk_isapi" : false,
    "bk_obj_id" : "bk_weblogic",
    "bk_property_id" : "bk_detail"
}, {
    "bk_property_group" : "default",
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_obj_id" : "bk_weblogic",
    "bk_property_index" : NumberLong(0),
    "bk_isapi" : false,
    "bk_supplier_account" : "0",
    "bk_property_name" : "JDK版本",
    "editable" : true,
    "ispre" : false,
    "option" : "",
    "bk_property_id" : "bk_jdk_version",
    "unit" : "",
    "placeholder" : "",
    "isrequired" : false,
    "isreadonly" : false,
    "bk_issystem" : false,
    "bk_property_type" : "longchar",
    "creator" : "cc_system"
}, {
    "bk_property_id" : "bk_jvm_free_mem",
    "bk_issystem" : false,
    "creator" : "cc_system",
    "bk_supplier_account" : "0",
    "bk_obj_id" : "bk_weblogic",
    "isreadonly" : false,
    "bk_property_type" : "singlechar",
    "bk_property_group" : "default",
    "bk_property_index" : NumberLong(0),
    "placeholder" : "",
    "bk_isapi" : false,
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_property_name" : "JVM配置的最大空闲内存",
    "unit" : "",
    "editable" : true,
    "ispre" : false,
    "isrequired" : false,
    "option" : ""
}, {
    "bk_supplier_account" : "0",
    "bk_obj_id" : "bk_weblogic",
    "bk_property_id" : "bk_jvm_capacity",
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_property_group" : "default",
    "placeholder" : "",
    "isreadonly" : false,
    "bk_isapi" : false,
    "isrequired" : false,
    "bk_issystem" : false,
    "unit" : "",
    "editable" : true,
    "ispre" : false,
    "creator" : "cc_system",
    "bk_property_name" : "JVM堆的当前大小",
    "bk_property_index" : NumberLong(0),
    "bk_property_type" : "singlechar",
    "option" : ""
}, {
    "bk_supplier_account" : "0",
    "bk_property_id" : "bk_jvm_used_mem",
    "bk_isapi" : false,
    "option" : "",
    "create_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "last_time" : ISODate("2019-09-03T03:41:40.909Z"),
    "bk_property_name" : "JVM堆的当前可用的内存",
    "unit" : "",
    "placeholder" : "",
    "bk_issystem" : false,
    "bk_property_type" : "singlechar",
    "creator" : "cc_system",
    "editable" : true,
    "ispre" : false,
    "isrequired" : false,
    "bk_property_index" : NumberLong(0),
    "isreadonly" : false,
    "bk_obj_id" : "bk_weblogic",
    "bk_property_group" : "default"
}] ;

const modelAttributeGroup = [
    {
        "bk_obj_id" : "bk_apache",
        "bk_supplier_account" : "0",
        "is_collapse" : false,
        "metadata" : {
            "label" : {}
        },
        "bk_group_index" : NumberLong(1),
        "ispre" : false,
        "bk_group_id" : "default",
        "bk_group_name" : "基础信息",
        "bk_isdefault" : true
    }, {
        "metadata" : {
            "label" : {}
        },
        "bk_group_id" : "default",
        "bk_group_index" : NumberLong(1),
        "bk_obj_id" : "bk_firewall",
        "is_collapse" : false,
        "bk_group_name" : "基础信息",
        "bk_supplier_account" : "0",
        "bk_isdefault" : true,
        "ispre" : false
    }, {
        "is_collapse" : false,
        "metadata" : {
            "label" : {}
        },
        "bk_group_id" : "default",
        "bk_group_name" : "基础信息",
        "bk_obj_id" : "bk_load_balance",
        "bk_isdefault" : true,
        "bk_group_index" : NumberLong(1),
        "bk_supplier_account" : "0",
        "ispre" : false
    }, {
        "ispre" : false,
        "bk_group_name" : "基础信息",
        "bk_group_index" : NumberLong(1),
        "bk_isdefault" : true,
        "is_collapse" : false,
        "metadata" : {
            "label" : {}
        },
        "bk_group_id" : "default",
        "bk_obj_id" : "bk_router",
        "bk_supplier_account" : "0"
    }, {
        "bk_group_name" : "基础信息",
        "bk_obj_id" : "bk_switch",
        "bk_supplier_account" : "0",
        "is_collapse" : false,
        "bk_isdefault" : true,
        "ispre" : false,
        "metadata" : {
            "label" : {}
        },
        "bk_group_id" : "default",
        "bk_group_index" : NumberLong(1)
    }, {
        "bk_isdefault" : true,
        "bk_group_id" : "default",
        "bk_obj_id" : "bk_tomcat",
        "bk_group_name" : "基础信息",
        "bk_group_index" : NumberLong(1),
        "bk_supplier_account" : "0",
        "ispre" : false,
        "is_collapse" : false,
        "metadata" : {
            "label" : {}
        },
    }, {
        "bk_group_id" : "default",
        "bk_group_name" : "基础信息",
        "bk_group_index" : NumberLong(1),
        "ispre" : false,
        "is_collapse" : false,
        "metadata" : {
            "label" : {}
        },
        "bk_obj_id" : "bk_weblogic",
        "bk_supplier_account" : "0",
        "bk_isdefault" : true
    }
] ;

function getNextSequence(name) {
    let ret = cmdb.cc_idgenerator.findAndModify(
        {
            query: { _id: name },
            update: { $inc: { SequenceID: 1 } },
            new: true
        }
    ) ;
    return ret.SequenceID;
}

function fixMissingModels() {
    const collection = cmdb.cc_ObjDes ;
    for (let idx=0; idx<models.length; idx++) {
        let model = models[idx] ;
        let count = collection.find({bk_obj_id: model.bk_obj_id}).count() ;
        if (count > 0) {
            print("model ", model.bk_obj_id, " already exist") ;
            continue
        }
        model.id = getNextSequence('cc_ObjDes') ;
        model.create_time = new Date() ;
        model.last_time = new Date() ;
        let result = collection.insert(model) ;
        print('insert model [', model.bk_obj_id, '] result is: ', result) ;
    }
}

function fixMissingModelAttributes() {
    const collection = cmdb.cc_ObjAttDes ;
    for (let idx = 0; idx<modelAttributes.length; idx++) {
        let attribute = modelAttributes[idx] ;
        const filter = {
            bk_obj_id: attribute.bk_obj_id, 
            bk_property_id: attribute.bk_property_id
        } ;
        let count = collection.find(filter).count() ;
        if (count > 0) {
            print('model [', attribute.bk_obj_id, '] \'s attribute [', attribute.bk_property_id, '] already exist') ;
            continue
        }
        attribute.id = getNextSequence('cc_ObjAttDes') ;
        attribute.create_time = new Date() ;
        attribute.last_time = new Date() ;
        let result = collection.insert(attribute) ;
        print('insert model attribute [', attribute.bk_obj_id, '-', attribute.bk_property_id, '] result is: ', result) ;
    }
}

function fixMissingModelAttributeGroup() {
    const collection = cmdb.cc_PropertyGroup ;
    for (let idx = 0; idx<modelAttributeGroup.length; idx++) {
        let group = modelAttributeGroup[idx] ;
        const filter = {
            bk_obj_id: group.bk_obj_id,
            bk_group_id: group.bk_group_id
        } ;
        let count = collection.find(filter).count() ;
        if (count > 0) {
            print('model attribute group [', group.bk_obj_id, ' - ', group.bk_group_id, '] already exist') ;
            continue
        }
        group.id = getNextSequence('cc_PropertyGroup') ;
        let result = collection.insert(group) ;
        print('insert model attribute group [', group.bk_obj_id, ' - ', group.bk_group_id, '] result is: ', result) ;
    }
}

// run fix
fixMissingModels() ;
fixMissingModelAttributes() ;
fixMissingModelAttributeGroup() ;
